package com.springboot_intr2.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.springboot_intr2.mapper.DeptMapper;
import com.springboot_intr2.pojo.Dept;
import com.springboot_intr2.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptMapper dm;

    @Override
    public List<Dept> getAll() {
        return dm.getAll();
    }

    @Override
    public Dept getOne(Integer deptno) {
        return dm.getOne(deptno);
    }

    @Override
    public int save(Dept dept) {
        return dm.save(dept);
    }

    @Override
    public PageInfo<Dept> bypage(Integer pageNo){
        pageNo = pageNo == null || pageNo == 0 ? 1 : pageNo;
        PageHelper.startPage(pageNo,4);
        PageInfo<Dept> info = new PageInfo<>(dm.getAll());
        return info;
    }
}
